﻿using Architecture.API.Application.TraceabilityCommand.PictureCommand;
using MediatR;
using Traceability.Domain.Service.PictureService;

namespace Architecture.API.Application.TraceabilityCommandHandler.PictureCommandHandler
{
    /// <summary>
    /// 
    /// </summary>
    public class PictureRemoveCommadHandler : IRequestHandler<PictureRemoveCommad, int>
    {
        /// <summary>
        /// 图片服务
        /// </summary>
        protected readonly IPictureService pictureService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="pictureService">图片服务</param>
        public PictureRemoveCommadHandler(IPictureService pictureService)
        {
            this.pictureService = pictureService;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>返回受影响的行数</returns>
        public async Task<int> Handle(PictureRemoveCommad request, CancellationToken cancellationToken)
        {
            return await pictureService.DeletedPicture(request.PictureId,request.UserName);
        }
    }
}
